// 1.引入二次封装后的axios
import request from '@/utils/request'
import type {
  HospitalInfoResponseData,
  HospitalLevelAndRegionResponseData,
  HospitalResponseData,
} from './type'

// 2.枚举首页需要的接口地址
enum API { // 枚举值为常量大写
  // 获取已有的医院的接口地址
  HOSPITAL_URL = '/hosp/hospital/',
  // 获取医院等级或地区的接口地址
  HOSPITAL_LEVEL_OR_REGION_URL = '/cmn/dict/findByDictCode/',
  // 根据关键字获取数据的接口地址
  HOSPITAL_INFO_URL = '/hosp/hospital/findByHosname/',
}
// 3.暴露请求方法
// 获取已有的医院的接口的方法
export const reqHospital = (
  page: number,
  limit: number,
  levelValue: string,
  districtCode: string,
) =>
  request.get<any, HospitalResponseData>(
    API.HOSPITAL_URL +
      `${page}/${limit}?hostype=${levelValue}&districtCode=${districtCode}`,
  )
// 获取医院等级或地区的接口的方法
export const reqHospitalLevelOrRegion = (dictCode: string) =>
  // dictCode为Hostype:获取医院等级、Beijin:获取地区
  request.get<any, HospitalLevelAndRegionResponseData>(
    API.HOSPITAL_LEVEL_OR_REGION_URL + dictCode,
  )
// 根据关键字获取医院列表的方法
export const reqHospitalInfo = (hosname: string) =>
  request.get<any, HospitalInfoResponseData>(API.HOSPITAL_INFO_URL + hosname)
